<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>我的订单</title>
    <script src="/common/js/jquery.min.js" type="text/javascript"></script>
    <script src="/common/layui/layui.js" type="text/javascript"></script>
    <script src="/common/layui/layui.all.js" type="text/javascript"></script>
    <script src="/common/js/userServer.js" type="text/javascript"></script>
    <link rel="stylesheet" href="/common/layui/css/layui.css">
</head>
<body>
<hr>
<div class="layui-row">
    <div class="layui-col-md3">
        <div class="layui-form-item">
            <label class="layui-form-label">商品名称：</label>
            <div class="layui-input-block">
                <input class="layui-input"  type="text" id="sname" name="sname" lay-verity="required"  autocomplete="off"
                />
            </div>
        </div>
    </div>
    <div class="layui-col-md1">
        <div class="layui-form-item">
            <!--<label class="layui-form-label">商品状态：</label>-->
            <!--<div class="layui-input-block">-->
            <input type="button" class="layui-input" value="查询" onclick="queryData()"
                   style="width: 100px;margin-left: 30px; background-color: #f7514d"></input>
            <!--</div>-->
        </div>
    </div>
</div>
<hr>
<table class="layui-hide" id="test" lay-filter="test"></table>

<script type="text/html" id="toolbarDemo">
    <div class="layui-btn-container">
        <!--<button class="layui-btn layui-btn-sm" onclick="queryData()" >查询</button>-->
        <!--                <button class="layui-btn layui-btn-sm" lay-event="getCheckLength">新增用户</button>-->
        <!--        <button class="layui-btn layui-btn-sm" lay-event="isAll">验证是否全选</button>-->
    </div>
</script>
<script type="text/html" id="barDemo">
    {{# if(d.type == "2"){ }}
    <a class="layui-btn layui-btn-danger layui-btn-xs"  lay-event="view">查看</a>
    {{#  } }}
</script>
<script src="/common/js/jquery-2.1.4.js" charset="utf-8"></script>
<script src="/common/layui/layui.js" charset="utf-8"></script>
<script src="/common/js/userServer.js" charset="utf-8"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->


<script>
    var static_index ="";
    var col = [
        {type: 'checkbox', fixed: 'left'}
        , {field: 'bid', title: '订单号', sort: true}
        , {field: 'sname', title: '商品名称'}
        , {field: 'total_amount', title: '支付金额'}
        , {field: 'types', title: '支付类别'}
        , {field: 'states', title: '支付状态'}
        , {field: 'paydate', title: '支付时间'}
        , {field: 'refunddate', title: '退款时间'}
        , {fixed: 'right', title: '操作', toolbar: '#barDemo'}
    ];
    layui.use('table', function () {
        var table = layui.table;

        table.render({
            elem: '#test'
            , url: '/getData/toMyOrder'
            , toolbar: '#toolbarDemo' //开启头部工具栏，并为其绑定左侧模板
            , page: true
            , id: 'testTable'
            , height: 615
            , request: {
                pageName: 'curr' //页码的参数名称，默认：page
                , limitName: 'nums' //每页数据量的参数名，默认：limit
            }
            , defaultToolbar: ['filter']
            , title: '类型数据表'
            , cols: [
                col
            ]
        });
        // $('table.layui-table thead tr th:eq(0)').addClass('layui-hide');
        // $('table:eq(1).layui-table thead tr th:eq(0)').addClass('layui-hide');
        // $('table:eq(6).layui-table thead tr th:eq(1)').addClass('layui-hide');

        //监听行工具事件
        table.on('tool(test)', function (obj) {
            var data = obj.data;
            console.log(data)
            if (obj.event === 'view') {
                //打开查看窗口
                var sid =data.sid;
                layer.open({
                    type: 2,
                    area: ['1000px', '700px'],
                    skin: 'layui-layer-rim', //加上边框
                    // btn: ['关闭','false'],
                    shadeClose:true,
                    content: ["/goods/openGoodsDetailView.do?sid="+sid, 'no'],
                    success:function(layero,index) {
                        static_index = index;
                        var iframe = window['layui-layer-iframe' + index];
                        iframe.child("view");
                    }
                });
            }
        });
    });

    function queryData() {
        var table = layui.table;
        var index = layer.msg("查询中，请等待...",{icon:16,tiem:false,shade:0});
        setTimeout(function () {
            table.reload('testTable',{
                page:{
                    curr:1
                },
                where:{
                    sname : $("#sname").val()
                }
            });
            layer.close(index);
        })
    }

    function closeWindow() {
        layer.close(static_index);
    }
</script>

</body>
</html>